package com.edu.exam.enums.questionbank;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 单选题状态枚举
 */
public enum SingleChoiceQuestionStatus implements BaseEnum {
    DRAFT("DRAFT", "草稿"),
    PENDING_REVIEW("PENDING_REVIEW", "待审核"),
    APPROVED("APPROVED", "已审核"),
    PUBLISHED("PUBLISHED", "已发布"),
    ARCHIVED("ARCHIVED", "已归档"),
    DELETED("DELETED", "已删除");

    private final String code;
    private final String description;

    SingleChoiceQuestionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static SingleChoiceQuestionStatus fromCode(String code) {
        for (SingleChoiceQuestionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown single choice question status code: " + code);
    }

    public static SingleChoiceQuestionStatus fromDescription(String description) {
        for (SingleChoiceQuestionStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown single choice question status description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}